<template>
  <div>
    <div>
      <p>用户名：<input type="text" v-model="username" /></p>
      <p>密码：<input type="password" v-model="password" /></p>
      <p>
        <button @click="login">登录</button>
      </p>
    </div>
  </div>
</template>

<script>
export default {
  data () {
    return {
      username: '',
      password: ''
    }
  },
  methods: {
    login () {
      if (this.username === 'admin' && this.password === '123456') {
        // alert('登录成功')

        // 编程式导航
        // this.$router.push('/layout')
        this.$router.push('/layout/user')
      } else {
        alert('用户名或是密码错误')
      }
    }
  }
}
</script>
